﻿@using ImpressionPrint.Utility
@using ImpressionPrint.Model
@*@model InvokeResult<List<OrderDetail>>*@
@{
    ViewBag.Title = "木知春冲印";
    Layout = "~/Views/Home/TemplateLayout.cshtml";
}
<script>
    var objOrderDetails;
    var OrderChose = function (oid) {
        var mobile = getUrlParam("m");
        location.href = "./PhotoListPage?m=" + mobile + "&oid=" + oid
    }

    var SubmitOrderInfo=function(){
        //判断数量是否正确
        objOrderDetails=@Html.Raw(ViewBag.order);
        if(objOrderDetails!=null && objOrderDetails.data!=null)
        {
            for(var i=0;i<objOrderDetails.data.length;i++)
            {
                var onum=objOrderDetails.data[i].num;
                var uploadnum=objOrderDetails.data[i].uploadnum;
                if(onum!=uploadnum)
                {
                    $('#dialog2').show().on('click', '.weui_btn_dialog', function () {
                        $('#dialog2').off('click').hide();
                    });
                    return;
                }
                //if(objOrderDetails.data[i].images!=null && objOrderDetails.data[i].images.length>0)
                //{
                //    for(var j=0;j<objOrderDetails.data[i].images.length;j++)
                //    {

                //    }
                //}
                //else
                //{
                //    $('#dialog2').show().on('click', '.weui_btn_dialog', function () {
                //        $('#dialog2').off('click').hide();
                //    });
                //    return;
                //}
            }
            var mobile = getUrlParam("m");
            //提交数据
            $.ajax({
                type: "get",
                url: "./SumbitAllOrder?m=" + mobile,
                //async:false,
                //data:JSON.stringify(objOrderDetails),
                datatype: "json",
                success: function (data) {
                    var obj=$.parseJSON(data);
                    alert(obj.ok);
                    if(obj.ok)
                    {
                        $('#dialog1').show().on('click', '.weui_btn_dialog', function () {
                            $('#dialog2').off('click').hide();
                            location.href="./OrderEnterPage";
                        });
                    }
                }
            });
        }
        else
        {
            $('#dialog2').show().on('click', '.weui_btn_dialog', function () {
                $('#dialog2').off('click').hide();
            });
            return;
        }
    }
</script>
<div class="hd">
    <img src="~/Images/head.jpg" class="head_jpg" />
</div>
<div class="bd">

    <div class="weui_tab_bd">
        <div class="weui_panel weui_panel_access">
            @if (Model != null && Model.data != null)
            {
                <div class="weui_panel_hd">订单产品列表</div>
                <div class="weui_panel_bd">
                    @foreach (var item in Model.data)
                    {
                        <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg" onclick="OrderChose('@item.no');">
                            <div class="weui_media_hd">
                                <img class="weui_media_appmsg_thumb" src="@item.imgurl" alt="">
                            </div>
                            <div class="weui_media_bd">
                                <h4 class="weui_media_title">@item.size @item.paper (<b style="color: red">@item.uploadnum</b>/@item.num)</h4>
                                <p class="weui_media_desc">@item.name</p>
                            </div>
                        </a>
                    }
                </div>
                <div class="weui_uploader_hd weui_cell">
                    <div class="weui_cell_bd weui_cell_primary"><a class="weui_btn weui_btn_primary" href="javascript:" onclick="SubmitOrderInfo();" id="showTooltips">提交订单</a></div>
                    <div class="weui_cell_ft"></div>
                </div>
            }
            else
            {
                <div class="weui_panel_hd">没有找到订单或者订单已经上传，请联系客服，或者<a href="http://weidian.com/s/338618746?wfr=c" style="font-weight: blod;">【立即前往下单】</a></div>
            }
        </div>
    </div>
</div>
<!--BEGIN dialog1-->
<div class="weui_dialog_alert" id="dialog1" style="display: none; position: relative; z-index: 99999;">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">系统提示</strong></div>
        <div class="weui_dialog_bd">订单提交成功</div>
        <div class="weui_dialog_ft">
            <a href="javascript:;" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>
<!--END dialog2-->
<!--BEGIN dialog2-->
<div class="weui_dialog_alert" id="dialog2" style="display: none; position: relative; z-index: 99999;">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">系统提示</strong></div>
        <div class="weui_dialog_bd">照片数量和订单数量不一致，请确认后提交</div>
        <div class="weui_dialog_ft">
            <a href="javascript:;" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>
<!--END dialog2-->
